package com.onlygx.dva.config;

import com.onlygx.dva.config.annotation.user.DevUserHandlerMethodArgumentResolver;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述 : 解决跨域和部分映射问题
 *
 * @author GaoXiang
 * @version V1.1
 * @since 19-5-8
 */
@Configuration
@ServletComponentScan
@RequiredArgsConstructor
public class BaseWebConfiguration implements WebMvcConfigurer {


    @Resource
    DevUserHandlerMethodArgumentResolver devUserHandlerMethodArgumentResolver;

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        WebMvcConfigurer.super.addArgumentResolvers(argumentResolvers);
        //注入的参数解析器
        argumentResolvers.add(devUserHandlerMethodArgumentResolver);
    }

/*
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 解决swagger无法访问
        registry.addResourceHandler("/ip-developer/swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");

        // 解决swagger的js文件无法访问
        registry.addResourceHandler("/ip-developer/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");

    }*/

    /*@Override
    public void addInterceptors(@Nonnull InterceptorRegistry registry) {
        WebMvcConfigurer.super.addInterceptors(registry);
        *//*registry.addInterceptor(userInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludePath);*//*
    }*/

}
